//
//  VEHomeAttentionTableViewCell.m
//  VET
//
//  Created by BlueWind on 2018/8/31.
//  Copyright © 2018年 BlueWind. All rights reserved.
//  首页关注 cell

#import "VEHomeAttentionTableViewCell.h"


#define SW [UIScreen mainScreen].bounds.size.width

@implementation VEHomeAttentionTableViewCell

{
    UIImageView *_headImage; /**<头像*/
    
    UILabel *_title; /**<标题*/
    
    UILabel *_timeAndAnchor; /**<时间作者*/
    
    UIButton *_attentionButton; /**<关注*/
    
    UILabel *_summary; /**<描述*/
    
    UIImageView *_newsImage; /**<图片*/
    
}

/** 返回循环利用的cell */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self= [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self loadDefaultSetting];
    }
    return self;
}

/** 加载默认UI元素和需要的数据 */
- (void)loadDefaultSetting {
    
    
    _headImage = [UIImageView new];
    [self.contentView addSubview:_headImage];
    [_headImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15);
        make.left.equalTo(self.contentView).offset(15);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    _headImage.layer.cornerRadius = 20;
    _headImage.layer.masksToBounds = YES;
    _headImage.image = [UIImage imageNamed:@"First_PlaceHolder"];

    _title = [UILabel new];
    [self.contentView addSubview:_title];
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self->_headImage);
        make.left.equalTo(self->_headImage.mas_right).offset(8);
        make.right.lessThanOrEqualTo(self.contentView).offset(60);
    }];
    _title.text = @"小强";
    _title.font = [UIFont systemFontOfSize:16];
    
    _timeAndAnchor = [UILabel new];
    [self.contentView addSubview:_timeAndAnchor];
    [_timeAndAnchor mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self->_headImage);
        make.left.equalTo(self->_title);
        make.right.lessThanOrEqualTo(self.contentView).offset(60);
    }];
    _timeAndAnchor.font = [UIFont systemFontOfSize:14];
    _timeAndAnchor.textColor = [UIColor lightGrayColor];
    _timeAndAnchor.text = @"08-06 阿斯顿发生";
    
    _newsImage = [UIImageView new];
    [self.contentView addSubview:_newsImage];
    [_newsImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self->_headImage.mas_bottom).offset(8);
        make.right.equalTo(self.contentView).offset(-15);
        make.size.mas_equalTo(CGSizeMake(110, 70));
    }];
    _newsImage.contentMode = UIViewContentModeScaleAspectFill;
    _newsImage.image = [UIImage imageNamed:@"First_PlaceHolder"];
    
    _summary = [UILabel new];
    [self.contentView addSubview:_summary];
    [_summary mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self->_newsImage);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self->_newsImage.mas_left).offset(-8);
    }];
    _summary.font = [UIFont systemFontOfSize:16];
    _summary.numberOfLines = 3;
    _summary.text = @"雅加达亚运会田径比赛完美收官，中国军团表现的不错，比如苏炳添打破亚运会纪录拿到100米飞人大战的金牌，确实很振奋人心，期待中国田径队在2020年东京奥运会上有更好的表现。";
    
    NSArray *titleArray = @[@"2",@"18"];
    
    for (NSInteger index = 0; index < titleArray.count ; index ++) {
        RankButton *button = [RankButton buttonWithType:(UIButtonTypeCustom)];
        button.picTileRange = 5;
        [self.contentView addSubview:button];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.contentView).offset(-GAP8);
            make.left.equalTo(self.contentView).offset(SW/2 * index);
            make.size.mas_equalTo(CGSizeMake(SW/2, 49));
        }];
        [button setImage:[UIImage imageNamed:titleArray[index]] forState:(UIControlStateNormal)];
        [button setTitle:@"234" forState:(UIControlStateNormal)];
    }
    
    UIView *line = [UIView new];
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView);
        make.right.equalTo(self.contentView);
        make.height.mas_equalTo(GAP8);
    }];
    line.backgroundColor = [UIColor colorWithHexString:kCommonBgColor];
    
}

//- (void)setModel:(VEFastModel *)model {
//    _model = model;
//    _title.text = model.ARTICLETITLE;
//    _author.text = model.ARTICLETYPE;
//    _timeLabel.text = [NSDate dateDescriptionWithTargetDate:model.RELEASETIME andTargetDateFormat:@"yyyy/MM/dd HH:mm:ss"];
//    
//    [_newsImage setImageWithUrlString:model.ARTICLEMSG palceHolderImage:[UIImage imageNamed:@"First_PlaceHolder"]];
//    
//}












@end
